<div class="content">

    <div class="panel panel-default panel-intro">
        <div class="panel-body">


            <form class="form-horizontal form-commonsearch nice-validator n-default n-bootstrap" novalidate="" method="post" action="/admin/product/product_zf_add">
                <input type="hidden" value="{$id}" name="id">
                <input type="hidden" value="{$pid}" name="pid">
                <fieldset style="width:70%;">
                    <div class="row">
                        <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                            <div class="col-xs-8">
                                <select class="form-control" name="lx">
                                    <option value="1" {if $lx == 1} selected {/if}>ID搜索</option>
                                    <option value="2" {if $lx == 2} selected {/if}>标题搜索</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                            <div class="col-xs-8" >
                                <input type="text" class="form-control" name="val" value="{$val}" placeholder="ID或标题" id="id" data-index="1" style="width: 200px;">
                            </div>
                        </div>

                        <button type="submit" class="btn btn-success" formnovalidate="" >提交</button>

                    </div>
                </fieldset>
            </form>





            <div id="" class="tab-content">
                <div class="tab-pane fade active in" id="one">
                    <div class="widget-body no-padding">
                        <div class="bootstrap-table">
                            <div class="fixed-table-toolbar">
                                <table id="" class="table table-striped table-bordered table-hover table-nowrap" data-operate-edit="1" data-operate-del="1" width="100%">
                                    <thead>
                                    <tr>
                                        <th style="text-align: center; vertical-align: middle;width:10%;height: 45px;" data-field="id">
                                            <div class="th-inner ">自费ID</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:40%;" data-field="fid">
                                            <div class="th-inner ">产品标题</div>
                                        </th>

                                        <th style="text-align: center; vertical-align: middle;width:10%;" data-field="type">
                                            <div class="th-inner ">建议价格</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:10%;" data-field="type">
                                            <div class="th-inner ">实施价格</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:10%;" data-field="type">
                                            <div class="th-inner ">儿童价</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:10%;" data-field="type">
                                            <div class="th-inner ">折扣%</div>
                                        </th>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:10%;" data-field="operate">
                                            <div class="th-inner ">操作</div>
                                        </th>
                                    </tr>
                                    </thead>
                                    <form action="" method="post" id="sort_f">
                                        <input type="hidden" id="tr_id" value="{$route_find.id}">
                                        <input type="hidden" id="p_id" value="{$route_find.p_id}">
                                        <tbody data-listidx="0">
                                        {volist name="list" id="vo"}
                                        <tr>
                                            <td style="text-align: center; vertical-align: middle; ">{$vo.id}</td>
                                            <td style="text-align: center; vertical-align: middle; ">{$vo.p_name}</td>
                                            <td style="text-align: center; vertical-align: middle; "></td>
                                            <td style="text-align: center; vertical-align: middle; ">
                                                <input type="text" style="width: 70px;height: 30px;" {if $vo['show']} value="{$vo.cyj}"   disabled {/if}>
                                            </td>
                                            <td style="text-align: center; vertical-align: middle; ">
                                                <input type="text" style="width: 70px;height: 30px;" {if $vo['show']} value="{$vo.etj}" disabled {/if}>
                                            </td>
                                            <td style="text-align: center; vertical-align: middle; ">
                                                <input type="text" style="width: 70px;height: 30px;" {if $vo['show']} value="{$vo.zk}" disabled {/if}>
                                            </td>
                                            <td style="text-align: center; vertical-align: middle; ">
                                                {if $vo['show']}
                                                    <a href="javascript:void ;"  class="btn btn-success btn-add disabled show" title="已添加" >
                                                        <i class="fa fa-plus"></i> 已添加
                                                    </a>
                                                {else}
                                                    <a href="javascript:void ;" zf_id="{$vo.id}" id="add{$vo.id}" class="btn btn-success btn-add " title="添加">
                                                        <i class="fa fa-plus"></i> 添加
                                                    </a>
                                                {/if}
                                            </td>
                                        </tr>
                                        {/volist}

                                    </form>

                                </table>
                            </div>
                            <div class="pull-right pagination">
                                {$page->render()}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<style>
    .show{background:darkred;}
</style>
<script src="/assets/libs/jquery/dist/jquery.min.js"></script>

<script>
    var tr_id = $("#tr_id").val();
    var p_id = $("#p_id").val();
    $(".btn-add").click(function () {
        //折扣
        var zk = $(this).parent().prev().children().val();
        //儿童价
        var etj = $(this).parent().prev().prev().children().val();
        //实施价
        var cyj = $(this).parent().prev().prev().prev().children().val();
        //自费项目id
        var zf_id = $(this).attr("zf_id");

        $.ajax({
            type:"POST",
            url:"/admin/product/zf_add",
            data:{zf_id:zf_id,p_id:p_id,etj:etj,cyj:cyj,tr_id:tr_id,zk:zk},
            dataType:"html",
            success:function(data){
                if(data==1){
                    $("#add"+zf_id).addClass("disabled");
                    $("#add"+zf_id).css("background","darkred");
                    $("#add"+zf_id).html("已添加");
                    parent.location.reload();
                }
            },
            error:function(data){
                alert("添加失败！");
            }
        });
    })





</script>